/**
*
* Titre : Job.java
* Description :
* Copyright : Copyright (c) 2013 JN Mauclair
* @author : JN MAUCLAIR
* @version : $Revision: $
*
* $Author$
* $Date$
*
*/
package fr.mauclair.domogeek.persist;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Version;

@Entity
public class Job {

	@Id
	@GeneratedValue
	private Long id;

	@Version
	private Long version;

	private String name;

	private boolean activate;
	private Date modificationDate;
	private JobType type = JobType.UNIQ;
	private Date dateStart;
	private int everySec;

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "job")
	private Set<JobAction> jobActions = new HashSet<JobAction>();

	public Job() {
	}

	public Long getId() {
		return id;
	}

	public Long getVersion() {
		return version;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public boolean isActivate() {
		return activate;
	}

	public void setActivate(boolean activate) {
		this.activate = activate;
	}

	public Date getModificationDate() {
		return modificationDate;
	}

	public void setModificationDate(Date modificationDate) {
		this.modificationDate = modificationDate;
	}

	public JobType getType() {
		return type;
	}

	public void setType(JobType type) {
		this.type = type;
	}

	public Date getDateStart() {
		return dateStart;
	}

	public void setDateStart(Date dateStart) {
		this.dateStart = dateStart;
	}

	public int getEverySec() {
		return everySec;
	}

	public void setEverySec(int everySec) {
		this.everySec = everySec;
	}

	public Set<JobAction> getJobActions() {
		return jobActions;
	}

	public void setJobActions(Set<JobAction> jobActions) {
		this.jobActions = jobActions;
	}

	public void addJobActions(JobAction jobAction) {
		this.jobActions.add(jobAction);
	}


//	@PrePersist
//	public void setType() {
//		this.type = JobType.UNIQ;
//	}

}
